home *** CD-ROM | disk | FTP | other *** search
/ Champak 50 / Volume 50 - JOGO DISK .iso / Games / moonstonemadness.swf / scripts / __Packages / TakGround.as < prev    next >
Encoding:
Text File  |  2007-09-27  |  27.2 KB  |  857 lines

  1. class TakGround extends SideScroller.MovingObject
  2. {
  3.    var bReactToCollisions;
  4.    var bGoingLeft;
  5.    var bGoingRight;
  6.    var nMSLostTimer;
  7.    var bCrouched;
  8.    var bEasterEgg;
  9.    var aEEObj;
  10.    var bReachedEnd;
  11.    var nSmokeDelay;
  12.    var oKeysManager;
  13.    var oBoarSound;
  14.    var oBoarStepSound;
  15.    var bPepperReaction;
  16.    var nPepperColor;
  17.    var bPepperColorActive;
  18.    var mcRef;
  19.    var oStunnedSound;
  20.    var oPepperLoopSound;
  21.    var oPepperStartSound;
  22.    var bNeedToCrouch;
  23.    var oLayer;
  24.    var nSpeedX;
  25.    var nPepperTimer;
  26.    var nStunnedTime;
  27.    var sState;
  28.    var bShouldMove;
  29.    static var oCtrl;
  30.    static var BOAR_SOUNDS = ["Boar_Sound_01.mp3","Boar_Sound_02.mp3","Boar_Sound_03.mp3","Boar_Sound_04.mp3","Boar_Sound_05.mp3","Boar_Sound_06.mp3","Boar_Sound_07.mp3","Boar_Sound_08.mp3","Boar_Sound_09.mp3","Boar_Sound_10.mp3","Boar_Sound_11.mp3"];
  31.    static var BOAR_STEP_SOUNDS = ["Boar_Step_01.mp3","Boar_Step_02.mp3","Boar_Step_03.mp3","Boar_Step_04.mp3","Boar_Step_05.mp3","Boar_Step_06.mp3","Boar_Step_07.mp3","Boar_Step_08.mp3","Boar_Step_09.mp3"];
  32.    static var SMOKE_DELAY = 3;
  33.    static var SMOKE_RANDOM = 3;
  34.    static var CROUCH_SPEED = 8;
  35.    static var CRUISE_CONTROL_SPEED = 9;
  36.    static var SLOW_DOWN_SPEED = 4;
  37.    static var RUN_SPEED = 14;
  38.    static var SPEED_CHANGE = 1.2;
  39.    static var MIN_SPEED_AIR = 4;
  40.    static var MAX_SPEED_AIR = 11;
  41.    static var MOY_SPEED_AIR = 8;
  42.    static var ACCELERATION_AIR = 0.25;
  43.    static var DIRECTION_CHANGE_FACTOR_AIR = 0.85;
  44.    static var JUMPSPEED = 14;
  45.    static var STUNNED_TIME = 22;
  46.    static var EASTER_EGG_KEY = "E";
  47.    static var BOAR_SOUND_KEY = "B";
  48.    static var CAMERA_GAP_SPEED_CHANGE = 1.5;
  49.    static var CAMERA_GAP_SPEED_CHANGE_FAST = 3.5;
  50.    static var nPEPPER_REACTION_TIME = 90;
  51.    static var nPEPPER_FLASH_INTERVAL = 3;
  52.    static var nINVINCINBLE_SPEED_MOD = 1.5;
  53.    static var nMINIMUM_DELAY_MS_LOST = 90;
  54.    function TakGround(__mcRef, __oLayer)
  55.    {
  56.       super(__mcRef,__oLayer);
  57.       TakGround.oCtrl = this;
  58.       this.bReactToCollisions = !Main.Instance.CodeBoxManager.Invincible;
  59.       this.bGoingLeft = false;
  60.       this.bGoingRight = false;
  61.       this.nMSLostTimer = 0;
  62.       this.bCrouched = false;
  63.       this.bEasterEgg = false;
  64.       this.aEEObj = new Array();
  65.       this.bReachedEnd = false;
  66.       this.nSmokeDelay = TakGround.SMOKE_DELAY;
  67.       this.oKeysManager = new Library.Utils.KeysManager();
  68.       this.oKeysManager.setListenerForKey(this,String(TakGround.EASTER_EGG_KEY).charCodeAt(0));
  69.       this.oKeysManager.setListenerForKey(this,String(TakGround.BOAR_SOUND_KEY).charCodeAt(0));
  70.       this.oKeysManager.setListenerForKey(this,38);
  71.       this.oKeysManager.setListenerForKey(this,40);
  72.       this.oKeysManager.setListenerForKey(this,37);
  73.       this.oKeysManager.setListenerForKey(this,39);
  74.       this.oKeysManager.setListenerForKey(this,32);
  75.       this.setState("CruiseControl");
  76.    }
  77.    static function get Instance()
  78.    {
  79.       return TakGround.oCtrl;
  80.    }
  81.    function doBoarSound()
  82.    {
  83.       if(Library.Sound.SoundManager.SoundsQty <= 6)
  84.       {
  85.          var _loc2_ = Library.Utils.MoreMath.getRandomRange(0,TakGround.BOAR_SOUNDS.length - 1);
  86.          var _loc3_ = TakGround.BOAR_SOUNDS[_loc2_];
  87.          this.oBoarSound.doStop();
  88.          this.oBoarSound = Library.Sound.SoundManager.doPlaySoundInCat(Main.SOUND_CAT_SOUND,_loc3_,180,1);
  89.       }
  90.    }
  91.    function doBoarStepSound()
  92.    {
  93.       if(Library.Sound.SoundManager.SoundsQty <= 6)
  94.       {
  95.          var _loc2_ = Library.Utils.MoreMath.getRandomRange(0,TakGround.BOAR_STEP_SOUNDS.length - 1);
  96.          var _loc3_ = TakGround.BOAR_STEP_SOUNDS[_loc2_];
  97.          this.oBoarStepSound.doStop();
  98.          this.oBoarStepSound = Library.Sound.SoundManager.doPlaySoundInCat(Main.SOUND_CAT_SOUND,_loc3_);
  99.       }
  100.    }
  101.    function doEnterFrame()
  102.    {
  103.       super.doEnterFrame();
  104.       this.nMSLostTimer = this.nMSLostTimer - 1;
  105.       if(this.bPepperReaction)
  106.       {
  107.          this.nPepperColor = this.nPepperColor - 1;
  108.          if(this.nPepperColor <= 0)
  109.          {
  110.             this.bPepperColorActive = !this.bPepperColorActive;
  111.             this.nPepperColor = TakGround.nPEPPER_FLASH_INTERVAL;
  112.             if(this.bPepperColorActive)
  113.             {
  114.                var _loc4_ = [1.68562018483454,0.129222856217665,-1.06484304105221,0,-29.125,-0.506833163112779,1.05012620416499,0.206706958947793,0,-29.125,0.46966683688722,-1.37227714378233,1.65261030689511,0,-29.125,0,0,0,1,0];
  115.                var _loc5_ = new flash.filters.ColorMatrixFilter(_loc4_);
  116.                this.mcRef.filters = [_loc5_];
  117.             }
  118.             else
  119.             {
  120.                this.mcRef.filters = [];
  121.             }
  122.          }
  123.       }
  124.       for(var _loc3_ in this.aEEObj)
  125.       {
  126.          if(this.aEEObj[_loc3_]._currentframe == undefined)
  127.          {
  128.             this.aEEObj.splice(Number(_loc3_),1);
  129.          }
  130.       }
  131.    }
  132.    function doPause()
  133.    {
  134.       super.doPause();
  135.       this.oStunnedSound.doPause();
  136.       this.oPepperLoopSound.doPause();
  137.       this.oPepperStartSound.doPause();
  138.       for(var _loc4_ in this.aEEObj)
  139.       {
  140.          for(var _loc3_ in this.aEEObj[_loc4_])
  141.          {
  142.             this.aEEObj[_loc4_][_loc3_].stop();
  143.          }
  144.       }
  145.    }
  146.    function doResume()
  147.    {
  148.       super.doResume();
  149.       this.oStunnedSound.doResume();
  150.       this.oPepperLoopSound.doResume();
  151.       this.oPepperStartSound.doResume();
  152.       for(var _loc4_ in this.aEEObj)
  153.       {
  154.          for(var _loc3_ in this.aEEObj[_loc4_])
  155.          {
  156.             this.aEEObj[_loc4_][_loc3_].play();
  157.          }
  158.       }
  159.       if(this.mcRef.mcHeadSwing.mcAnim._currentframe == 1)
  160.       {
  161.          this.mcRef.mcHeadSwing.mcAnim.stop();
  162.       }
  163.       var _loc5_ = true;
  164.       if(this.CurrentState.indexOf("Stunned") != -1)
  165.       {
  166.          _loc5_ = false;
  167.       }
  168.       else if(this.CurrentState.indexOf("Feather") != -1)
  169.       {
  170.          _loc5_ = false;
  171.       }
  172.       else if(this.CurrentState.indexOf("Jump") != -1)
  173.       {
  174.          _loc5_ = false;
  175.       }
  176.       this.bGoingLeft = this.oKeysManager.isKeyDown(37);
  177.       this.bGoingRight = this.oKeysManager.isKeyDown(39);
  178.       this.bNeedToCrouch = this.oKeysManager.isKeyDown(40);
  179.       this.bCrouched = this.bNeedToCrouch;
  180.       if(_loc5_)
  181.       {
  182.          this.doUnlockState();
  183.          if(!this.bCrouched)
  184.          {
  185.             if(!this.bPepperReaction)
  186.             {
  187.                if(this.bGoingLeft)
  188.                {
  189.                   this.setState("SlowDown");
  190.                }
  191.                else if(this.bGoingRight)
  192.                {
  193.                   this.setState("Run");
  194.                }
  195.                else
  196.                {
  197.                   this.setState("CruiseControl");
  198.                }
  199.             }
  200.             else
  201.             {
  202.                this.setState("Run");
  203.             }
  204.          }
  205.          else
  206.          {
  207.             this.setState("CrouchRun");
  208.          }
  209.       }
  210.    }
  211.    function doSoundEvent(__nEvent, __oSound)
  212.    {
  213.       if(__nEvent === Library.Sound.SoundManager.EVENT_SOUND_COMPLETE)
  214.       {
  215.          if(__oSound == this.oStunnedSound)
  216.          {
  217.             delete this.oStunnedSound;
  218.          }
  219.          if(__oSound == this.oPepperLoopSound)
  220.          {
  221.             delete this.oPepperLoopSound;
  222.          }
  223.          if(__oSound == this.oPepperStartSound)
  224.          {
  225.             delete this.oPepperStartSound;
  226.             this.oPepperLoopSound = Library.Sound.SoundManager.doPlaySoundInCat(Main.SOUND_CAT_SOUND,"PimentActive.wav",100,9999);
  227.          }
  228.       }
  229.    }
  230.    function onKeyManagerEvent(__nEvent, __nCode)
  231.    {
  232.       if(!this.Paused)
  233.       {
  234.          switch(__nEvent)
  235.          {
  236.             case Library.Utils.KeysManager.EVENT_KEY_DOWN:
  237.                switch(__nCode)
  238.                {
  239.                   case String(TakGround.EASTER_EGG_KEY).charCodeAt(0):
  240.                      this.onToggleEE();
  241.                      break;
  242.                   case String(TakGround.BOAR_SOUND_KEY).charCodeAt(0):
  243.                      this.doBoarSound();
  244.                      break;
  245.                   case 37:
  246.                      this.bGoingLeft = true;
  247.                      if(!this.bPepperReaction)
  248.                      {
  249.                         if(!this.bCrouched)
  250.                         {
  251.                            this.setState("SlowDown");
  252.                         }
  253.                         else
  254.                         {
  255.                            this.setState("CrouchRun");
  256.                         }
  257.                      }
  258.                      break;
  259.                   case 39:
  260.                      this.bGoingRight = true;
  261.                      if(!this.bPepperReaction)
  262.                      {
  263.                         if(!this.bCrouched)
  264.                         {
  265.                            this.setState("Run");
  266.                         }
  267.                         else
  268.                         {
  269.                            this.setState("CrouchRun");
  270.                         }
  271.                      }
  272.                      break;
  273.                   case 40:
  274.                      this.setState("CrouchRun");
  275.                      this.bNeedToCrouch = true;
  276.                      break;
  277.                   case 38:
  278.                      if(!this.bCrouched)
  279.                      {
  280.                         this.setState("JumpStart");
  281.                      }
  282.                      break;
  283.                   case 32:
  284.                      if(this.mcRef.mcHeadSwing != undefined)
  285.                      {
  286.                         if(this.mcRef.mcHeadSwing.mcAnim._currentframe == 1)
  287.                         {
  288.                            this.mcRef.mcHeadSwing.mcAnim.play();
  289.                            var _loc3_ = Library.Utils.MoreMath.getRandomRange(1,3);
  290.                            var _loc2_ = "new_boar_head_swing-0" + _loc3_ + ".mp3";
  291.                            Library.Sound.SoundManager.isSoundPlaying("new_boar_head_swing-01.mp3").oSound.doStop();
  292.                            Library.Sound.SoundManager.isSoundPlaying("new_boar_head_swing-02.mp3").oSound.doStop();
  293.                            Library.Sound.SoundManager.isSoundPlaying("new_boar_head_swing-03.mp3").oSound.doStop();
  294.                            Library.Sound.SoundManager.doPlaySoundInCat(Main.SOUND_CAT_SOUND,_loc2_);
  295.                         }
  296.                      }
  297.                }
  298.                break;
  299.             case Library.Utils.KeysManager.EVENT_KEY_UP:
  300.                switch(__nCode)
  301.                {
  302.                   case 37:
  303.                      this.bGoingLeft = false;
  304.                      if(!this.bPepperReaction)
  305.                      {
  306.                         if(this.bGoingRight)
  307.                         {
  308.                            if(!this.bCrouched)
  309.                            {
  310.                               this.setState("Run");
  311.                            }
  312.                            else
  313.                            {
  314.                               this.setState("CrouchRun");
  315.                            }
  316.                         }
  317.                         else if(!this.bCrouched)
  318.                         {
  319.                            this.setState("CruiseControl");
  320.                         }
  321.                         else
  322.                         {
  323.                            this.setState("CrouchRun");
  324.                         }
  325.                      }
  326.                      break;
  327.                   case 39:
  328.                      this.bGoingRight = false;
  329.                      if(!this.bPepperReaction)
  330.                      {
  331.                         if(this.bGoingLeft)
  332.                         {
  333.                            if(!this.bCrouched)
  334.                            {
  335.                               this.setState("SlowDown");
  336.                            }
  337.                            else
  338.                            {
  339.                               this.setState("CrouchRun");
  340.                            }
  341.                         }
  342.                         else if(!this.bCrouched)
  343.                         {
  344.                            this.setState("CruiseControl");
  345.                         }
  346.                         else
  347.                         {
  348.                            this.setState("CrouchRun");
  349.                         }
  350.                      }
  351.                      break;
  352.                   case 40:
  353.                      if(!this.bPepperReaction)
  354.                      {
  355.                         if(this.bGoingLeft)
  356.                         {
  357.                            this.setState("SlowDown");
  358.                         }
  359.                         else if(this.bGoingRight)
  360.                         {
  361.                            this.setState("Run");
  362.                         }
  363.                         else
  364.                         {
  365.                            this.setState("CruiseControl");
  366.                         }
  367.                      }
  368.                      else
  369.                      {
  370.                         this.setState("Run");
  371.                      }
  372.                      this.bNeedToCrouch = false;
  373.                }
  374.          }
  375.       }
  376.    }
  377.    function onHitSpecial(__oRef)
  378.    {
  379.       if(__oRef instanceof MiniStone)
  380.       {
  381.          Game.Instance.onCatchMiniStone();
  382.       }
  383.       else if(__oRef instanceof MoonStone)
  384.       {
  385.          Game.Instance.onCatchMoonstone();
  386.       }
  387.       else if(__oRef instanceof Feather)
  388.       {
  389.          this.doForcedSetState("FeatherCatch");
  390.          this.doLockState();
  391.       }
  392.       else if(__oRef instanceof Pepper)
  393.       {
  394.          this.doPepperReaction();
  395.       }
  396.       else if(__oRef instanceof EndTrigger)
  397.       {
  398.          if(!this.bReachedEnd)
  399.          {
  400.             LevelManager.Instance.onTakReachEnd();
  401.             this.bReachedEnd = true;
  402.          }
  403.       }
  404.    }
  405.    function onBackFromMiniGame()
  406.    {
  407.       this.doForcedSetState("FeatherBackOnEarth");
  408.    }
  409.    function doReactCollision()
  410.    {
  411.       if(!Main.Instance.CodeBoxManager.Invincible)
  412.       {
  413.          this.doForcedSetState("StunnedStart");
  414.          this.doLockState();
  415.          if(Game.Instance.MSQty > 0 && this.nMSLostTimer <= 0)
  416.          {
  417.             var _loc3_ = this.oLayer.doAttachVisual("mcMoonStoneLost");
  418.             _loc3_._x = this.mcRef._x;
  419.             _loc3_._y = this.mcRef._y;
  420.             var _loc4_ = new MSLost(_loc3_,this.oLayer);
  421.             this.nMSLostTimer = TakGround.nMINIMUM_DELAY_MS_LOST;
  422.             Game.Instance.onLostMoonstone();
  423.          }
  424.          super.doReactCollision();
  425.       }
  426.       else
  427.       {
  428.          Library.Sound.SoundManager.doPlaySoundInCat(Main.SOUND_CAT_SOUND,"ItemHit.mp3");
  429.       }
  430.    }
  431.    function doSetEEOn(__mc)
  432.    {
  433.       if(!Library.Utils.Tools.isItemInArray(this.aEEObj,__mc))
  434.       {
  435.          this.aEEObj.push(__mc);
  436.       }
  437.       __mc.gotoAndStop(this.EeLabel);
  438.    }
  439.    function doDestroy()
  440.    {
  441.       delete this.oBoarSound;
  442.       delete this.oBoarStepSound;
  443.       delete this.aEEObj;
  444.       this.oKeysManager.doDestroy();
  445.       delete this.oKeysManager;
  446.       this.oStunnedSound.doDestroy();
  447.       delete this.oStunnedSound;
  448.       delete TakGround.oCtrl;
  449.       super.doDestroy();
  450.    }
  451.    function get EeLabel()
  452.    {
  453.       var _loc2_ = "Male";
  454.       if(this.bEasterEgg)
  455.       {
  456.          _loc2_ = "Female";
  457.       }
  458.       return _loc2_;
  459.    }
  460.    function get IsInHeadSwing()
  461.    {
  462.       var _loc2_ = undefined;
  463.       if(this.mcRef.mcHeadSwing.mcAnim._currentframe == undefined)
  464.       {
  465.          _loc2_ = false;
  466.       }
  467.       else
  468.       {
  469.          _loc2_ = this.mcRef.mcHeadSwing.mcAnim._currentframe != 1;
  470.       }
  471.       return _loc2_;
  472.    }
  473.    function doFeatherBackOnEarth()
  474.    {
  475.       if(this.isStateComplete())
  476.       {
  477.          this.doUnlockState();
  478.          this.bCrouched = false;
  479.          if(!this.bPepperReaction)
  480.          {
  481.             this.setState("CruiseControl");
  482.          }
  483.          else
  484.          {
  485.             this.setState("Run");
  486.          }
  487.       }
  488.       this.doNormalizeCameraGap(TakGround.CAMERA_GAP_SPEED_CHANGE);
  489.       this.nSpeedX = 0;
  490.    }
  491.    function doFeatherNoTak()
  492.    {
  493.       this.doSetSpeeds(undefined,-1,true);
  494.    }
  495.    function doFeatherCatch()
  496.    {
  497.       this.mcRef._rotation = 0;
  498.       if(this.isStateComplete())
  499.       {
  500.          this.doForcedSetState("FeatherNoTak");
  501.          Game.Instance.onFeatherCatch();
  502.       }
  503.       this.doSetSpeeds(undefined,-1,true);
  504.       this.doNormalizeCameraGap(TakGround.CAMERA_GAP_SPEED_CHANGE);
  505.    }
  506.    function doJumpLoop()
  507.    {
  508.       this.doJumpMove();
  509.    }
  510.    function doJumpStart()
  511.    {
  512.       if(this.isStateComplete())
  513.       {
  514.          this.doForcedSetState("JumpLoop");
  515.       }
  516.       this.doJumpMove();
  517.    }
  518.    function doCrouchRun()
  519.    {
  520.       var _loc2_ = undefined;
  521.       if(this.bPepperReaction)
  522.       {
  523.          _loc2_ = TakGround.RUN_SPEED;
  524.       }
  525.       else
  526.       {
  527.          _loc2_ = TakGround.CROUCH_SPEED;
  528.       }
  529.       if(Main.Instance.CodeBoxManager.Invincible)
  530.       {
  531.          _loc2_ *= TakGround.nINVINCINBLE_SPEED_MOD;
  532.       }
  533.       this.nSpeedX = Library.Utils.MoreMath.getReachNum(this.nSpeedX,_loc2_,TakGround.SPEED_CHANGE);
  534.       this.doAddSmoke();
  535.       this.doNormalizeCameraGap(TakGround.CAMERA_GAP_SPEED_CHANGE);
  536.    }
  537.    function doCruiseControl()
  538.    {
  539.       var _loc2_ = TakGround.CRUISE_CONTROL_SPEED;
  540.       if(Main.Instance.CodeBoxManager.Invincible)
  541.       {
  542.          _loc2_ *= TakGround.nINVINCINBLE_SPEED_MOD;
  543.       }
  544.       this.nSpeedX = Library.Utils.MoreMath.getReachNum(this.nSpeedX,_loc2_,TakGround.SPEED_CHANGE);
  545.       this.doAddSmoke();
  546.       this.doNormalizeCameraGap(TakGround.CAMERA_GAP_SPEED_CHANGE);
  547.    }
  548.    function doRun()
  549.    {
  550.       if(this.bPepperReaction)
  551.       {
  552.          this.nPepperTimer = this.nPepperTimer - 1;
  553.          if(this.nPepperTimer <= 0)
  554.          {
  555.             this.bPepperReaction = false;
  556.             this.mcRef.filters = [];
  557.             this.oPepperLoopSound.doFadeTo(0);
  558.             if(!this.bGoingRight)
  559.             {
  560.                if(this.bGoingLeft)
  561.                {
  562.                   this.setState("SlowDown");
  563.                }
  564.                else
  565.                {
  566.                   this.setState("CruiseControl");
  567.                }
  568.             }
  569.          }
  570.       }
  571.       var _loc2_ = TakGround.RUN_SPEED;
  572.       if(Main.Instance.CodeBoxManager.Invincible)
  573.       {
  574.          _loc2_ *= TakGround.nINVINCINBLE_SPEED_MOD;
  575.       }
  576.       this.nSpeedX = Library.Utils.MoreMath.getReachNum(this.nSpeedX,_loc2_,TakGround.SPEED_CHANGE);
  577.       this.doAddSmoke();
  578.       this.doEnlargeCameraGap(TakGround.CAMERA_GAP_SPEED_CHANGE_FAST);
  579.    }
  580.    function doSlowDown()
  581.    {
  582.       this.nSpeedX = Library.Utils.MoreMath.getReachNum(this.nSpeedX,TakGround.SLOW_DOWN_SPEED,TakGround.SPEED_CHANGE);
  583.       this.doAddSmoke();
  584.       this.doReduceCameraGap(TakGround.CAMERA_GAP_SPEED_CHANGE_FAST);
  585.    }
  586.    function doStunnedEnd()
  587.    {
  588.       if(this.isStateComplete())
  589.       {
  590.          this.doUnlockState();
  591.          if(!this.bNeedToCrouch)
  592.          {
  593.             if(!this.bPepperReaction)
  594.             {
  595.                if(this.bGoingLeft)
  596.                {
  597.                   this.setState("SlowDown");
  598.                }
  599.                else if(this.bGoingRight)
  600.                {
  601.                   this.setState("Run");
  602.                }
  603.                else
  604.                {
  605.                   this.setState("CruiseControl");
  606.                }
  607.             }
  608.             else
  609.             {
  610.                this.setState("Run");
  611.             }
  612.          }
  613.          else
  614.          {
  615.             this.setState("CrouchRun");
  616.          }
  617.       }
  618.       this.doNormalizeCameraGap(3);
  619.    }
  620.    function doStunnedStart()
  621.    {
  622.       if(this.isStateComplete())
  623.       {
  624.          this.nStunnedTime = TakGround.STUNNED_TIME;
  625.          this.doForcedSetState("StunnedLoop");
  626.       }
  627.       this.doNormalizeCameraGap(TakGround.CAMERA_GAP_SPEED_CHANGE);
  628.    }
  629.    function doStunnedLoop()
  630.    {
  631.       this.nSpeedX = Library.Utils.MoreMath.getReachZero(this.nSpeedX,2.5);
  632.       if(this.nStunnedTime > 0)
  633.       {
  634.          this.nStunnedTime = this.nStunnedTime - 1;
  635.       }
  636.       else
  637.       {
  638.          this.doForcedSetState("StunnedEnd");
  639.       }
  640.       this.doNormalizeCameraGap(TakGround.CAMERA_GAP_SPEED_CHANGE);
  641.    }
  642.    function doPepperReaction()
  643.    {
  644.       this.nPepperTimer = TakGround.nPEPPER_REACTION_TIME;
  645.       this.bPepperReaction = true;
  646.       if(!this.bCrouched)
  647.       {
  648.          this.setState("Run");
  649.       }
  650.       else
  651.       {
  652.          this.setState("CrouchRun");
  653.       }
  654.       this.oPepperStartSound.doStop();
  655.       delete this.oPepperStartSound;
  656.       this.oPepperLoopSound.doStop();
  657.       delete this.oPepperLoopSound;
  658.       this.oPepperStartSound = Library.Sound.SoundManager.doPlaySoundInCat(Main.SOUND_CAT_SOUND,"CatchPiment.mp3");
  659.       this.oPepperStartSound.doAddListener(this);
  660.       this.bPepperColorActive = false;
  661.       this.nPepperColor = TakGround.nPEPPER_FLASH_INTERVAL;
  662.    }
  663.    function onToggleEE()
  664.    {
  665.       this.bEasterEgg = !this.bEasterEgg;
  666.       for(var _loc2_ in this.aEEObj)
  667.       {
  668.          this.aEEObj[_loc2_].gotoAndStop(this.EeLabel);
  669.       }
  670.       this.doBoarSound();
  671.    }
  672.    function doNormalizeCameraGap(__nChange)
  673.    {
  674.       if(SideScroller.SideScrollerManager.Instance.CameraManager.FollowAddonX > 0)
  675.       {
  676.          SideScroller.SideScrollerManager.Instance.CameraManager.FollowAddonX = SideScroller.SideScrollerManager.Instance.CameraManager.FollowAddonX - __nChange;
  677.          if(SideScroller.SideScrollerManager.Instance.CameraManager.FollowAddonX < 0)
  678.          {
  679.             SideScroller.SideScrollerManager.Instance.CameraManager.FollowAddonX = 0;
  680.          }
  681.       }
  682.       else if(SideScroller.SideScrollerManager.Instance.CameraManager.FollowAddonX < 0)
  683.       {
  684.          SideScroller.SideScrollerManager.Instance.CameraManager.FollowAddonX = SideScroller.SideScrollerManager.Instance.CameraManager.FollowAddonX + __nChange;
  685.          if(SideScroller.SideScrollerManager.Instance.CameraManager.FollowAddonX > 0)
  686.          {
  687.             SideScroller.SideScrollerManager.Instance.CameraManager.FollowAddonX = 0;
  688.          }
  689.       }
  690.    }
  691.    function doReduceCameraGap(__nChange)
  692.    {
  693.       if(SideScroller.SideScrollerManager.Instance.CameraManager.FollowAddonX > -100)
  694.       {
  695.          SideScroller.SideScrollerManager.Instance.CameraManager.FollowAddonX = SideScroller.SideScrollerManager.Instance.CameraManager.FollowAddonX - __nChange;
  696.       }
  697.    }
  698.    function doEnlargeCameraGap(__nChange)
  699.    {
  700.       if(SideScroller.SideScrollerManager.Instance.CameraManager.FollowAddonX < 175)
  701.       {
  702.          SideScroller.SideScrollerManager.Instance.CameraManager.FollowAddonX = SideScroller.SideScrollerManager.Instance.CameraManager.FollowAddonX + __nChange;
  703.       }
  704.    }
  705.    function doAddSmoke()
  706.    {
  707.       if(this.nSmokeDelay == 0)
  708.       {
  709.          this.nSmokeDelay = TakGround.SMOKE_DELAY;
  710.          var _loc3_ = undefined;
  711.          if(Main.Instance.CodeBoxManager.Invincible)
  712.          {
  713.             _loc3_ = "Dynamic_TrailStar";
  714.          }
  715.          else
  716.          {
  717.             _loc3_ = "Dynamic_TrailSmoke";
  718.          }
  719.          var _loc2_ = this.ParentLayer.doAttachVisual(_loc3_);
  720.          _loc2_._x = this.Ref._x + Library.Utils.MoreMath.getRandomRange(- TakGround.SMOKE_RANDOM,TakGround.SMOKE_RANDOM);
  721.          _loc2_._y = this.Ref._y + Library.Utils.MoreMath.getRandomRange(- TakGround.SMOKE_RANDOM,TakGround.SMOKE_RANDOM);
  722.          var _loc4_ = new TrailSmoke(_loc2_,this.ParentLayer);
  723.       }
  724.       else
  725.       {
  726.          this.nSmokeDelay = this.nSmokeDelay - 1;
  727.       }
  728.    }
  729.    function doJumpMove()
  730.    {
  731.       if(this.bGoingRight || this.bPepperReaction)
  732.       {
  733.          if(this.nSpeedX < 0)
  734.          {
  735.             this.nSpeedX *= TakGround.DIRECTION_CHANGE_FACTOR_AIR;
  736.          }
  737.          var _loc2_ = TakGround.MAX_SPEED_AIR;
  738.          if(Main.Instance.CodeBoxManager.Invincible)
  739.          {
  740.             _loc2_ *= TakGround.nINVINCINBLE_SPEED_MOD;
  741.          }
  742.          if(this.nSpeedX < _loc2_)
  743.          {
  744.             this.doSetSpeeds(TakGround.ACCELERATION_AIR,undefined,true);
  745.          }
  746.          else
  747.          {
  748.             this.nSpeedX = TakGround.MAX_SPEED_AIR;
  749.          }
  750.       }
  751.       else if(this.bGoingLeft)
  752.       {
  753.          if(this.nSpeedX > 0)
  754.          {
  755.             this.nSpeedX *= TakGround.DIRECTION_CHANGE_FACTOR_AIR;
  756.          }
  757.          if(this.nSpeedX > TakGround.MIN_SPEED_AIR)
  758.          {
  759.             this.doSetSpeeds(- TakGround.ACCELERATION_AIR,undefined,true);
  760.          }
  761.          else
  762.          {
  763.             this.nSpeedX = TakGround.MIN_SPEED_AIR;
  764.          }
  765.       }
  766.       else
  767.       {
  768.          this.nSpeedX = Library.Utils.MoreMath.getReachNum(this.nSpeedX,TakGround.MOY_SPEED_AIR,TakGround.ACCELERATION_AIR);
  769.       }
  770.       if(Main.Instance.CodeBoxManager.Invincible)
  771.       {
  772.          this.doAddSmoke();
  773.       }
  774.    }
  775.    function onHitGround()
  776.    {
  777.       if(this.CurrentState == "JumpStart" || this.CurrentState == "JumpLoop")
  778.       {
  779.          this.doUnlockState();
  780.          this.nSmokeDelay = 0;
  781.          if(!this.bNeedToCrouch)
  782.          {
  783.             if(!this.bPepperReaction)
  784.             {
  785.                if(this.bGoingLeft)
  786.                {
  787.                   this.setState("SlowDown");
  788.                }
  789.                else if(this.bGoingRight)
  790.                {
  791.                   this.setState("Run");
  792.                }
  793.                else
  794.                {
  795.                   this.setState("CruiseControl");
  796.                }
  797.             }
  798.             else
  799.             {
  800.                this.setState("Run");
  801.             }
  802.          }
  803.          else
  804.          {
  805.             this.setState("CrouchRun");
  806.          }
  807.          this.doBoarSound();
  808.       }
  809.    }
  810.    function doLoadStateAction()
  811.    {
  812.       super.doLoadStateAction();
  813.       switch(this.sState)
  814.       {
  815.          case "FeatherCatch":
  816.             Library.Sound.SoundManager.doPlaySoundInCat(Main.SOUND_CAT_SOUND,"Feather.mp3");
  817.             Library.Sound.SoundManager.doPlaySoundInCat(Main.SOUND_CAT_SOUND,"Feather_Go.mp3");
  818.             break;
  819.          case "StunnedStart":
  820.             Library.Sound.SoundManager.doPlaySoundInCat(Main.SOUND_CAT_SOUND,"Hurt.mp3",100,1,true);
  821.             this.bShouldMove = false;
  822.             break;
  823.          case "StunnedLoop":
  824.             this.oStunnedSound.doStop();
  825.             this.oStunnedSound.doDestroy();
  826.             delete this.oStunnedSound;
  827.             this.oStunnedSound = Library.Sound.SoundManager.doPlaySoundInCat(Main.SOUND_CAT_SOUND,"Stunned.mp3",100,999,true);
  828.             this.oStunnedSound.doAddListener(this);
  829.             break;
  830.          case "StunnedEnd":
  831.             this.oStunnedSound.setFadeRate(15);
  832.             this.oStunnedSound.doFadeTo(0);
  833.             this.bShouldMove = true;
  834.             break;
  835.          case "CrouchRun":
  836.             this.bCrouched = true;
  837.             this.doBoarSound();
  838.             break;
  839.          case "JumpStart":
  840.             this.doLockState();
  841.             this.doBoarSound();
  842.             this.doSetSpeeds(undefined,- TakGround.JUMPSPEED,true);
  843.             Library.Sound.SoundManager.doPlaySoundInCat(Main.SOUND_CAT_SOUND,"Jump.mp3");
  844.       }
  845.    }
  846.    function doUnLoadStateAction()
  847.    {
  848.       super.doUnLoadStateAction();
  849.       switch(this.sState)
  850.       {
  851.          case "CrouchIdle":
  852.          case "CrouchRun":
  853.             this.bCrouched = false;
  854.       }
  855.    }
  856. }
  857.